<template>
  <el-descriptions
      :column="1"
      border
      class="infoTable"
      title="基本信息"
  >

    <el-descriptions-item>
      <template #label>
        <span class="label">申请编号</span>
      </template>
      {{applyItem.applyId}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">申请类型</span>
      </template>
      {{typeString}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">日期</span>
      </template>
      {{applyItem.applyDate}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">学者编号</span>
      </template>
      <el-link :href="authorUrl" target="_blank">
        <span class="link">{{applyItem.authorId}}</span>
      </el-link>

    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">学者姓名</span>
      </template>
      <el-link :href="authorUrl" target="_blank">
        <span class="link">{{applyItem.authorName}}</span>
      </el-link>

    </el-descriptions-item>


    <el-descriptions-item>
      <template #label>
        <span class="label">备注说明</span>
      </template>
      {{applyItem.other}}
    </el-descriptions-item>

  </el-descriptions>

  <div style="margin-bottom: 10px"></div>
  <el-descriptions
      :column="1"
      border
      class="infoTable"
      title="文献信息"
  >
    <el-descriptions-item>
      <template #label>
        <span class="label">doi</span>
      </template>
      {{applyItem.doi}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">文献类型</span>
      </template>
      {{docType(applyItem.docType)}}
    </el-descriptions-item>
    
    <template v-if="applyItem.docType===1">
      <el-descriptions-item>
        <template #label>
          <span class="label">期刊名称</span>
        </template>
        {{applyItem.journal}}
      </el-descriptions-item>
    </template>

    <template v-else-if="applyItem.docType===2">
      <el-descriptions-item>
        <template #label>
          <span class="label">会议录名称</span>
        </template>
        {{applyItem.conferenceSeries}}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span class="label">会议名称</span>
        </template>
        {{applyItem.conferenceInstance}}
      </el-descriptions-item>
    </template>
    

    <el-descriptions-item>
      <template #label>
        <span class="label">文献标题</span>
      </template>
        {{applyItem.title}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">文献摘要</span>
      </template>
        {{applyItem.abstract_}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">发表日期</span>
      </template>
      {{applyItem.date}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">卷/册</span>
      </template>
      {{applyItem.volume}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">起止页码</span>
      </template>
      {{applyItem.firstPage}}——{{applyItem.lastPage}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">作者</span>
      </template>
      <span v-for="item in applyItem.authors">
        <el-link :href="authorUrl(item.authorId)" target="_blank">
          <span class="link">{{item.authorSequence+"—"+item.name}},&nbsp;</span>
        </el-link>
      </span>
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">学科领域</span>
      </template>
      <span v-for="item in applyItem.fields">
        {{item}},&nbsp;
      </span>
    </el-descriptions-item>
    <el-descriptions-item>
      <template #label>
        <span class="label">参考文献</span>
      </template>
      <div v-for="(item,index) in applyItem.references" style="margin-bottom: 5px">
        <el-link :href="paperUrl(item.paperId)" target="_blank">\
          <span class="link">[{{index+1}}]{{item.title}}</span>
        </el-link>
      </div>
    </el-descriptions-item>
    
  </el-descriptions>
</template>

<script>
export default {
  name: "AddApply",
  props:['applyItem'],
  data(){
    return{

    }
  },
  methods:{
    authorUrl(authorId){
      return `/portal?authorId=${authorId}`
    },
    paperUrl(paperId){
      return `/detail?paperId=${paperId}`
    },
    docType(docType){
      if(docType===1){
        return "期刊文献"
      }else if(docType===2){
        return "会议文献"
      }
    }
    
  },
  computed:{
    typeString(){
      switch (this.applyItem.type){
        case "claim":
          return "认领门户申请";
        case "add":
          return "上传文献申请";
        case "update":
          return "更新文献申请";
        case "delete":
          return "删除文献申请";
      }
    }
  }
}
</script>

<style scoped>
.infoTable{
  font-size: 16px;
  word-break: break-word;
}
.link{
  font-size: 16px;
}
.label{
  word-break: keep-all;
}
</style>